#delimit;
capture log close;
set more off;
pause on;
clear all;
set scheme plottig;
cap cd "/Users/deandulay/Dropbox/Myanmar_JOP_EGI_replication";
cap cd "C:\Users\ejm5\Dropbox\Myanmar_JOP_EGI_replication";
use  "data\20220606_mbei_panel_working.dta", clear;

/***********************************************************************************************************************************************************/
/*Figure F1 Diff-in-Diff Results by Agency and State/Region*/ 

#delimit;
generate DD= year*workshop;
#delimit;
lab var DD "Difference-in-Difference Coefficient";

#delimit;
foreach num in 1 2 3 4 5 6 7 8 9 10{;
generate s_`num'=subindex`num'_final;
svy: reg s_`num' year workshop DD i.capital   i.state_region;
estimates store model_s_`num';
};

#delimit;
foreach num in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15{;
svy: reg DAO_indicators_final  year workshop DD i.capital if state_region==`num';
estimates store model_DAO_`num';
svy: reg GAD_indicators_final  year workshop DD i.capital if state_region==`num';
estimates store model_GAD_`num';
};

#delimit;
svy: reg DAO_indicators_final year workshop DD i.capital   i.state_region;
estimates store model_DAO;
svy: reg GAD_indicators_final year workshop DD i.capital   i.state_region;
estimates store model_GAD;

#delimit;
coefplot model_DAO_1 model_DAO_2 model_DAO_3 model_DAO_4 model_DAO_5 model_DAO_6 model_DAO_7 model_DAO_8 model_DAO_9 model_DAO_10 model_DAO_11 model_DAO_12 model_DAO_13 model_DAO_14 model_DAO_15 , 
keep(DD) yline(0, lcolor(red) lwidth(thick) lpattern(dash))  
ytitle("Effect of Dissemination Workshop", margin(vsmall) orientation(vertical)) ylab(-1(.2)2, labsize(vsmall))
level(95) ciopts(lcolor(navy) lwidth(medthin)) vertical xtitle(, size(small) margin(medium)) 
msymbol(diamond) msize(small) title("", size(medium) margin(medium))
legend(size(tiny) rows(2) position(6) ring(0) label(2 "Kachin") label(4 "Kayah") label(6 "Kayin") label(8 "Chin") 
label(10 "Sagaing") label(11 "Tanintharyi") label(13 "Bago") label(15 "Magway") label(17 "Mandalay") label(18 "Mon")
label(19 "Rakhine") label(21 "Yangon") label(23 "Shan") label(25 "Ayeyarwady") label(27 "Naypyitaw"))
note("Range Bars=95% Confidence Intervals", size(tiny) position(7)) title("Development Affairs Offce Index",  size(medium) margin(small));
graph save "figures\FA_DAO.gph", replace;


#delimit;
coefplot model_GAD_1 model_GAD_2 model_GAD_3 model_GAD_4 model_GAD_5 model_GAD_6 model_GAD_7 model_GAD_8 model_GAD_9 model_GAD_10 model_GAD_11 model_GAD_12 model_GAD_13 model_GAD_14 model_GAD_15 , 
keep(DD) yline(0, lcolor(red) lwidth(thick) lpattern(dash))  
 ytitle("Effect of Dissemination Workshop", margin(vsmall) orientation(vertical)) ylab(-1(.2)2, labsize(vsmall))
level(95) ciopts(lcolor(navy) lwidth(medthin)) vertical xtitle(, size(small) margin(medium)) 
msymbol(diamond) msize(small) title("", size(medium) margin(medium))
legend(size(tiny) rows(2) position(6) ring(0) label(2 "Kachin") label(4 "Kayah") label(6 "Kayin") label(8 "Chin") 
label(10 "Sagaing") label(11 "Tanintharyi") label(13 "Bago") label(15 "Magway") label(17 "Mandalay") label(18 "Mon")
label(19 "Rakhine") label(21 "Yangon") label(23 "Shan") label(25 "Ayeyarwady") label(27 "Naypyitaw"))
note("Range Bars=95% Confidence Intervals", size(tiny) position(7)) title("General Administrative Department Index",  size(medium) margin(small));
graph save "figures\FA_GAD.gph", replace;


graph combine "figures\FA_DAO.gph" "figures\FA_GAD.gph", xcommon ycommon imargin(tiny);
graph save "figures\FigureF1.gph", replace;
graph export "figures\FigureF1.pdf", as(pdf) replace;
/***********************************************************************************************************************************************************/

/***********************************************************************************************************************************************************/
/*Figure: Diff-in-Diff Results for Whole Country*/ 
#delimit;
coefplot model_DAO model_GAD, 
keep(DD) yline(0, lcolor(red) lwidth(thick) lpattern(dash)) 
scheme(economist) yscale(alt) ytitle("Effect of Dissemination Workshop", orientation(vertical)) ylab(-.5(.05).5, labsize(vsmall))
level(95) ciopts(lcolor(navy) lwidth(medthin)) vertical xtitle(, size(small) margin(medium)) 
msymbol(diamond) msize(small) title("", size(medium) margin(medium))
legend(size(small) ring(0) rows(2) position(7) label(2 "Only DAO") label(4 "Only GAD"))
note("Range Bars=95% Confidence Intervals", size(tiny) position(7));
graph save "figures\Figure_DAOGAD.gph", replace;
graph export "figures\Figure_DAOGAD.pdf", as(pdf) replace;
/***********************************************************************************************************************************************************/
/*Figure: Subindicies*/ 
#delimit;
coefplot model_s_1  model_s_3  model_s_5 model_s_2 model_s_10 model_s_4 model_s_6 model_s_7 model_s_8 model_s_9, 
keep(DD) yline(0, lcolor(red) lwidth(thick) lpattern(dash)) 
 ytitle("Effect of Dissemination Workshop", orientation(vertical)) ylab(-.5(.05).5, labsize(vsmall))
level(95) ciopts(lcolor(navy) lwidth(medthin)) vertical xtitle(, size(small) margin(medium)) 
msymbol(diamond) msize(small) title("", size(medium) margin(medium))
legend(size(tiny) ring(0) rows(2) position(6) label(2 "Entry") label(8 "Land") label(4 "Post-Entry") label(12 "Informal Charges") 
label(6 "Infrastructure") label(14 "Transparency") label(16 "Favoritism") label(18 "Environment") label(20 "Labor") label(10 "Law & Order"))
note("Range Bars=95% Confidence Intervals", size(tiny) position(7));
graph save "figures\Figure_Subindices.gph", replace;
graph export "figures\Figure_Subindices.pdf", as(pdf) replace;
/***********************************************************************************************************************************************************/

/*********************MBEI NEW INDICATORS********************************/
/*Table F2 Impact of Facilitation by Agency on New 2020 Indicators*/
#delimit;
svy: reg DAO_finalNEW i.workshop;
outreg2 using "tables\TableF2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1)  symbol(***, **, *, ^) replace;

#delimit;
svy: reg DAO_finalNEW i.workshop i.capital i.state_region;
outreg2 using "tables\TableF2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg DAO_finalNEW i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableF2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg DAO_finalNEW i.workshop  i.state_region literacy surface_area lag if capital==0;
outreg2 using "tables\TableF2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) ;

#delimit;
svy: reg GAD_finalNEW i.workshop;
outreg2 using "tables\TableF2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1)  symbol(***, **, *, ^);

#delimit;
svy: reg GAD_finalNEW i.workshop i.capital i.state_region;
outreg2 using "tables\TableF2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg GAD_finalNEW i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableF2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

svy: reg GAD_finalNEW i.workshop  i.state_region literacy surface_area lag if capital==0;
outreg2 using "tables\TableF2", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;

/**********************************************************************************************************************/

/***********************************************************************************************************************************************************/
/*Table F4 Impact of Facilitation by Agency (Only Clustered SEs)*/
#delimit;
reg DAO_indicators_final i.year##i.workshop,  cluster(township);
outreg2 using "tables\TableF4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) replace;

areg DAO_indicators_final i.year##i.workshop i.capital , absorb(state_region) cluster(township);
outreg2 using "tables\TableF4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg DAO_indicators_final i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region) cluster(township);
outreg2 using "tables\TableF4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg DAO_indicators_final i.year##i.workshop  literacy surface_area lag if capital==0, absorb(state_region) cluster(township);
outreg2 using "tables\TableF4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

reg GAD_indicators_final i.year##i.workshop,  cluster(township);
outreg2 using "tables\TableF4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg GAD_indicators_final i.year##i.workshop i.capital , absorb(state_region) cluster(township);
outreg2 using "tables\TableF4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg GAD_indicators_final i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region) cluster(township);
outreg2 using "tables\TableF4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg GAD_indicators_final i.year##i.workshop  literacy surface_area lag if capital==0, absorb(state_region) cluster(township);
outreg2 using "tables\TableF4", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;

/**********************************************************************************************************************/
/*Table F5 Impact of Facilitation by Agency and Data Type on Core Indicators*/
/*Survey Data (Columns 1-4)*/

#delimit;
svy: reg DAO_indicators_soft i.year##i.workshop;
outreg2 using "tables\TableF5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) replace;

#delimit;
svy: reg DAO_indicators_soft i.year##i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableF5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

#delimit;
svy: reg GAD_indicators_soft i.year##i.workshop;
outreg2 using "tables\TableF5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

#delimit;
svy: reg GAD_indicators_soft i.year##i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableF5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);
/**********************************************************************************************************************/
/*Table F6 Impact of Facilitation by Agency and Data Type on New Indicators*/
/*Survey Data (Columns 1-4)*/
#delimit;
svy: reg DAO_surveyNEW i.workshop;
outreg2 using "tables\TableF6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) replace;

#delimit;
svy: reg DAO_surveyNEW i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableF6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

#delimit;
svy: reg GAD_surveyNEW i.workshop;
outreg2 using "tables\TableF6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

#delimit;
svy: reg GAD_surveyNEW i.workshop i.capital i.state_region literacy surface_area lag;
outreg2 using "tables\TableF6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);
/******************************************************************************************************************************************************/

/******************************************************************************************************************************************************/
/*Use Township Level Data Created in 2_SetUp.do*/
use  "data\20220606_mbei_township.dta", clear;
/******************************************************************************************************************************************************/

/******************************************************************************************************************************************************/
/*Table F7 Impact of Facilitation by Agency (Township Level)*/
#delimit;
reg DAO_indicators_final i.year##i.workshop;
outreg2 using "tables\TableF7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) replace;

areg DAO_indicators_final i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableF7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

reg GAD_indicators_final i.year##i.workshop;
outreg2 using "tables\TableF7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg GAD_indicators_final i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableF7", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;
/******************************************************************************************************************************************************/

/******************************************************************************************************************************************************/
/*Table F8 Impact of Facilitation by Agency on New Indicators (Township Level)*/
#delimit;
reg DAO_finalNEW i.workshop;
outreg2 using "tables\TableF8", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) replace;

areg DAO_finalNEW i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableF8", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

reg GAD_finalNEW i.workshop;
outreg2 using "tables\TableF8", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg GAD_finalNEW i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableF8", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;
/******************************************************************************************************************************************************/

/**********************************************************************************************************************/
/*Table F5 Impact of Facilitation by Agency and Data Type on Core Indicators*/
/*Hard Data (Columns 5-8)*/
#delimit;
reg DAO_indicators_hard i.year##i.workshop;
outreg2 using "tables\TableF5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg DAO_indicators_hard i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableF5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

reg GAD_indicators_hard i.year##i.workshop;
outreg2 using "tables\TableF5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg GAD_indicators_hard i.year##i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableF5", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;


/**********************************************************************************************************************/
/*Table F6 Impact of Facilitation by Agency and Data Type on New Indicators*/
/*Hard Data (Columns 5-8)*/
#delimit;
reg DAO_hardNEW i.workshop;
outreg2 using "tables\TableF6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg DAO_hardNEW i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableF6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

reg GAD_hardNEW i.workshop;
outreg2 using "tables\TableF6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^);

areg GAD_hardNEW i.workshop i.capital literacy surface_area lag, absorb(state_region);
outreg2 using "tables\TableF6", tdec(3) bdec(3) e(rmse) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) excel;
/**********************************************************************************************************************/